<template>
  <div class="page_main white_bg vp_detail">
    <section class="art_block">
      <h2 class="art_tit">{{ curPoint.point_name }}</h2>
      <p class="art_time">{{ curPoint.create_time }}</p>
      <div class="art_author">
        <img class="avat_img" :src="curPoint.face_image_small" width="40" height="40" />
        <p class="avat_name">{{ curPoint.name }}</p>
        <p class="avat_fans">粉丝数 {{ curPoint.fans_num }}</p>
        <button class="atten_btn" :class="{ atten_btn_yes: curPoint.status == '0' }" @click="addFoucs(curPoint.status)">
          {{ curPoint.status == '0' ? '已关注' : '关注' }}
        </button>
      </div>
      <!--未订阅状态 start-->
      <div class="art_content" v-if="curPoint.pck_id && curPoint.buy_status == '0'">
        <p>{{ curPoint.point_desc }}</p>
        <div class="rss_tip">订阅后即可解锁观点包内所有观点的私密部分，还可获取观点包更新提醒</div>
        <div class="rss_btn_box"><button class="rss_btn">订阅</button></div>
      </div>
      <!--未订阅状态 end-->
      <div class="art_content" v-else>
        {{ curPoint.point_content }}
      </div>
      <p class="art_tip">风险提示：以上内容仅代表个人观点，不构成投资建议。股市有风险，投资需谨慎</p>
      <div class="art_zan_box">
        <!--已经点赞状态 加上class：  -->
        <span class="art_zan" :class="{ art_zan_on: curPoint.like_status == '1' }" @click="addLike(curPoint.like_status)">
          {{ curPoint.like_num }}
        </span>
      </div>
    </section>
  </div>
</template>

<script>
import { queryViewpointDetail, addFoucsFun, addLikeFun } from '@/service/yewuServer'
export default {
  data() {
    return {
      dddd: 'dfdsf',
      curPoint: {},
    }
  },
  computed: {
    pointId() {
      return this.$route.params.pointId
    },
  },
  created() {
    queryViewpointDetail({
      point_id: this.pointId,
    }).then(
      res => {
        if (res.error_no == '0') {
          this.curPoint = res.results[0]
        }
      },
      err => {
        console.log(err)
      },
    )
  },
  methods: {
    pageBack() {
      this.$router.go(-1)
    },
    addFoucs(status) {
      addFoucsFun({
        user_id: this.curPoint.user_id,
        status: status == '0' ? '1' : '0',
      }).then(
        res => {
          if (res.error_no == '0') {
            this.curPoint.status = res.results[0].status
          }
        },
        err => {
          console.log(err)
        },
      )
    },
    addLike(status) {
      addLikeFun({
        type_no: this.curPoint.point_id,
        status: status == '0' ? '1' : '0',
      }).then(
        res => {
          if (res.error_no == '0') {
            this.curPoint.like_status = res.results[0].status
          }
        },
        err => {
          console.log(err)
        },
      )
    },
  },
}
</script>

<style></style>
